package com.tuling.jvm;

import java.util.ArrayList;

//字符串常量池的位置
public class RuntimeConstantPoolOOM {
    //字符串常量池位置 -Xms10M -Xmx10M
    public static void main(String[] args) {
        // JVM参数：-Xms10M -Xmx10M
        ArrayList<String> list = new ArrayList<String>();
        for (int i = 0; i < 1000000; i++) {
            for(int j = 0;j < 1000000; j++){
                list.add(String.valueOf(i + j/1000000).intern());
            }
        }
    }
    /**
     *  运行结果:
     * jdk7及以上：Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
     * jdk6：Exception in thread "main" java.lang.OutOfMemoryError: PermGen space(永久代空间)
     */
}

